﻿<UserControl x:Class="Test.Silverlight.DataGrid.RowTemplate"
    xmlns="http://schemas.microsoft.com/client/2007" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:grid="clr-namespace:DevExpress.AgDataGrid;assembly=DevExpress.AgDataGrid.v8.2"
    xmlns:internal="clr-namespace:DevExpress.AgDataGrid.Internal;assembly=DevExpress.AgDataGrid.v8.2"
    xmlns:sdkcontrols="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Extended"
    xmlns:local="clr-namespace:Test.Silverlight.DataGrid;assembly=Test.Silverlight.DataGrid">
    
	<UserControl.Resources>
		<DataTemplate x:Key="GridPreviewTemplate">
			<Grid Margin="5,5,5,5">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<Grid.Resources>
					<Style x:Name="BoldText" TargetType="TextBlock">
						<Setter Property="FontWeight" Value="Bold"/>
					</Style>
					<Style x:Name="HeaderText" TargetType="TextBlock">
						<Setter Property="FontSize" Value="16"/>
						<Setter Property="FontWeight" Value="Bold"/>
					</Style>
					<Style x:Name="ItalicText" TargetType="TextBlock">
						<Setter Property="FontStyle" Value="Italic"/>
					</Style>
					<Style x:Name="NormalText" TargetType="TextBlock"/>
					<local:DateToLongDateStringConverter x:Name="DateToLongDateStringConverter"/>
				</Grid.Resources>
				<Grid VerticalAlignment="Top" HorizontalAlignment="Left" Margin="16,16,12,16" Grid.Row="0" Grid.Column="0">
					<Border Margin="5,5,0,0" Background="Black" Opacity="0.15" CornerRadius="5"
							HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
					<Border Background="#FF6E6E6E" CornerRadius="4,4,4,4" Padding="4"
							HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,5,5">
						<Border Background="White" CornerRadius="2,2,2,2" Padding="3,3,3,3">
                            <Border.Resources>
                                <grid:AgDataGridImageColumnContentConverter x:Key="ImageContentConverter"/>
                            </Border.Resources>
                            <Image x:Name="Icon" Source="{Binding Photo, Converter={StaticResource ImageContentConverter}}" Width="120" Height="127" />
						</Border>
					</Border>
				</Grid>				
				<StackPanel Grid.Column="1" Grid.Row="0" Width="500" HorizontalAlignment="Left" Margin="0,16,0,0">
					<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,0,6">
						<TextBlock Style="{StaticResource HeaderText}" Text="{Binding FirstName}"/>
						<TextBlock Style="{StaticResource HeaderText}" Text=" "/>
						<TextBlock Style="{StaticResource HeaderText}" Text="{Binding LastName}"/>
					</StackPanel>
					<local:FlowStackPanel>
                        <TextBlock Style="{StaticResource BoldText}"   Text="{Binding FirstName}"/>			
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding LastName}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="was born on"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding BirthDate, Converter={StaticResource DateToLongDateStringConverter}}"/>
						<TextBlock Style="{StaticResource NormalText}" Text=". Now lives at"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding City}"/>
						<TextBlock Style="{StaticResource NormalText}" Text=","/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding Country}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="."/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding TitleOfCourtesy}"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding LastName}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="holds a position of"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding Title}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="our"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding Region}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="department, ("/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding City}"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding Country}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="). Joined our company on"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding HireDate, Converter={StaticResource DateToLongDateStringConverter}}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="."/>
					</local:FlowStackPanel>
					<Border Background="Transparent" Margin="0,0,0,6" />
					<StackPanel Orientation="Horizontal" Margin="0,0,0,16">
						<TextBlock Style="{StaticResource BoldText}" Text="Notes:" Width="50"/>
					<TextBlock Width="450" TextWrapping="Wrap" Style="{StaticResource ItalicText}" Text="{Binding Notes}"/>
				</StackPanel>
				</StackPanel>				
			</Grid>
		</DataTemplate>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot">
		<grid:AgDataGrid x:Name="grid" Grid.Column="0" ColumnsAutoWidth="True" PreviewVisibility="ForAllRows" PreviewTemplate="{StaticResource GridPreviewTemplate}">
			<grid:AgDataGrid.Columns>
				<grid:AgDataGridTextColumn FieldName="LastName" AllowResizing="False" AllowMoving="False" TextWrapping="Wrap"/>
				<grid:AgDataGridTextColumn FieldName="FirstName" AllowResizing="False" AllowMoving="False"/>
				<grid:AgDataGridTextColumn FieldName="Title" AllowResizing="False" AllowMoving="False"/>
				<grid:AgDataGridDateColumn FieldName="BirthDate" AllowResizing="False" AllowMoving="False"/>
				<grid:AgDataGridTextColumn FieldName="HomePhone" AllowResizing="False" AllowMoving="False"/>
			</grid:AgDataGrid.Columns>
			<grid:AgDataGrid.DataRowTemplate>
				<ControlTemplate TargetType="grid:AgDataGridRow">
					<Grid Name="RootElement">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto"/>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto" />
						</Grid.ColumnDefinitions>
						<internal:AgLineStackPanel x:Name="CellsPresenterElement" Height="1" Opacity="0"/>
						<ContentControl x:Name="PreviewPresenterElement" Height="0"/>
					</Grid>
				</ControlTemplate>
			</grid:AgDataGrid.DataRowTemplate>
		</grid:AgDataGrid>
	</Grid>
    
</UserControl>
